home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Interfaces & Libraries / Interfaces / PInterfaces / Drag.p < prev    next >
Encoding:
Text File  |  1995-07-06  |  13.8 KB  |  413 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        Drag.p
  3.  
  4.      Contains:    Drag and Drop Interfaces.
  5.  
  6.      Version:    Technology:    Macintosh Drag and Drop 1.1
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. }
  19.  
  20. {$IFC UNDEFINED UsingIncludes}
  21. {$SETC UsingIncludes := 0}
  22. {$ENDC}
  23.  
  24. {$IFC NOT UsingIncludes}
  25.  UNIT Drag;
  26.  INTERFACE
  27. {$ENDC}
  28.  
  29. {$IFC UNDEFINED __DRAG__}
  30. {$SETC __DRAG__ := 1}
  31.  
  32. {$I+}
  33. {$SETC DragIncludes := UsingIncludes}
  34. {$SETC UsingIncludes := 1}
  35.  
  36.  
  37. {$IFC UNDEFINED __APPLEEVENTS__}
  38. {$I AppleEvents.p}
  39. {$ENDC}
  40. {    Errors.p                                                    }
  41. {        ConditionalMacros.p                                        }
  42. {    Types.p                                                        }
  43. {    Memory.p                                                    }
  44. {        MixedMode.p                                                }
  45. {    OSUtils.p                                                    }
  46. {    Events.p                                                    }
  47. {        Quickdraw.p                                                }
  48. {            QuickdrawText.p                                        }
  49. {    EPPC.p                                                        }
  50. {        AppleTalk.p                                                }
  51. {        Files.p                                                    }
  52. {            Finder.p                                            }
  53. {        PPCToolbox.p                                            }
  54. {        Processes.p                                                }
  55. {    Notification.p                                                }
  56.  
  57. {$IFC UNDEFINED __TEXTEDIT__}
  58. {$I TextEdit.p}
  59. {$ENDC}
  60.  
  61. {$PUSH}
  62. {$ALIGN MAC68K}
  63. {$LibExport+}
  64.  
  65. CONST
  66. { Flavor Flags }
  67.     flavorSenderOnly            = $00000001;                    { flavor is available to sender only }
  68.     flavorSenderTranslated        = $00000002;                    { flavor is translated by sender }
  69.     flavorNotSaved                = $00000004;                    { flavor should not be saved }
  70.     flavorSystemTranslated        = $00000100;                    { flavor is translated by system }
  71.  
  72.     
  73. TYPE
  74.     FlavorFlags = LONGINT;
  75.  
  76.  
  77. CONST
  78. { Drag Attributes }
  79.     dragHasLeftSenderWindow        = $00000001;                    { drag has left the source window since TrackDrag }
  80.     dragInsideSenderApplication    = $00000002;                    { drag is occurring within the sender application }
  81.     dragInsideSenderWindow        = $00000004;                    { drag is occurring within the sender window }
  82.  
  83.     
  84. TYPE
  85.     DragAttributes = LONGINT;
  86.  
  87.  
  88. CONST
  89. { Special Flavor Types }
  90.     flavorTypeHFS                = 'hfs ';                        { flavor type for HFS data }
  91.     flavorTypePromiseHFS        = 'phfs';                        { flavor type for promised HFS data }
  92.     flavorTypeDirectory            = 'diry';
  93.  
  94. { Drag Tracking Handler Messages }
  95.     dragTrackingEnterHandler    = 1;                            { drag has entered handler }
  96.     dragTrackingEnterWindow        = 2;                            { drag has entered window }
  97.     dragTrackingInWindow        = 3;                            { drag is moving within window }
  98.     dragTrackingLeaveWindow        = 4;                            { drag has exited window }
  99.     dragTrackingLeaveHandler    = 5;                            { drag has exited handler }
  100.  
  101.     
  102. TYPE
  103.     DragTrackingMessage = INTEGER;
  104.  
  105.  
  106. CONST
  107. { Drag Drawing Procedure Messages }
  108.     dragRegionBegin                = 1;                            { initialize drawing }
  109.     dragRegionDraw                = 2;                            { draw drag feedback }
  110.     dragRegionHide                = 3;                            { hide drag feedback }
  111.     dragRegionIdle                = 4;                            { drag feedback idle time }
  112.     dragRegionEnd                = 5;                            { end of drawing }
  113.  
  114.     
  115. TYPE
  116.     DragRegionMessage = INTEGER;
  117.  
  118.  
  119. CONST
  120. { Zoom Acceleration }
  121.     zoomNoAcceleration            = 0;                            { use linear interpolation }
  122.     zoomAccelerate                = 1;                            { ramp up step size }
  123.     zoomDecelerate                = 2;                            { ramp down step size }
  124.  
  125.     
  126. TYPE
  127.     ZoomAcceleration = INTEGER;
  128.  
  129. { Drag Manager Data Types }
  130.     DragReference = LONGINT;
  131.  
  132.     ItemReference = LONGINT;
  133.  
  134.     FlavorType = ResType;
  135.  
  136. { HFS Flavors }
  137.     HFSFlavor = RECORD
  138.         fileType:                OSType;                                    { file type }
  139.         fileCreator:            OSType;                                    { file creator }
  140.         fdFlags:                INTEGER;                                { Finder flags }
  141.         fileSpec:                FSSpec;                                    { file system specification }
  142.     END;
  143.  
  144.     PromiseHFSFlavor = RECORD
  145.         fileType:                OSType;                                    { file type }
  146.         fileCreator:            OSType;                                    { file creator }
  147.         fdFlags:                INTEGER;                                { Finder flags }
  148.         promisedFlavor:            FlavorType;                                { promised flavor containing an FSSpec }
  149.     END;
  150.  
  151. { Application-Defined Drag Handler Routines }
  152.     DragTrackingHandlerProcPtr = ProcPtr;  { FUNCTION DragTrackingHandler(message: DragTrackingMessage; theWindow: WindowPtr; handlerRefCon: UNIV Ptr; theDragRef: DragReference): OSErr; }
  153.     DragTrackingHandlerUPP = UniversalProcPtr;
  154.  
  155. CONST
  156.     uppDragTrackingHandlerProcInfo = $00003FA0; { FUNCTION (2 byte param, 4 byte param, 4 byte param, 4 byte param): 2 byte result; }
  157.  
  158. FUNCTION NewDragTrackingHandlerProc(userRoutine: DragTrackingHandlerProcPtr): DragTrackingHandlerUPP;
  159.     {$IFC NOT GENERATINGCFM }
  160.     INLINE $2E9F;
  161.     {$ENDC}
  162.  
  163. FUNCTION CallDragTrackingHandlerProc(message: DragTrackingMessage; theWindow: WindowPtr; handlerRefCon: UNIV Ptr; theDragRef: DragReference; userRoutine: DragTrackingHandlerUPP): OSErr;
  164.     {$IFC NOT GENERATINGCFM}
  165.     INLINE $205F, $4E90;
  166.     {$ENDC}
  167.     
  168. TYPE
  169.     DragTrackingHandler = DragTrackingHandlerUPP;
  170.  
  171.     DragReceiveHandlerProcPtr = ProcPtr;  { FUNCTION DragReceiveHandler(theWindow: WindowPtr; handlerRefCon: UNIV Ptr; theDragRef: DragReference): OSErr; }
  172.     DragReceiveHandlerUPP = UniversalProcPtr;
  173.  
  174. CONST
  175.     uppDragReceiveHandlerProcInfo = $00000FE0; { FUNCTION (4 byte param, 4 byte param, 4 byte param): 2 byte result; }
  176.  
  177. FUNCTION NewDragReceiveHandlerProc(userRoutine: DragReceiveHandlerProcPtr): DragReceiveHandlerUPP;
  178.     {$IFC NOT GENERATINGCFM }
  179.     INLINE $2E9F;
  180.     {$ENDC}
  181.  
  182. FUNCTION CallDragReceiveHandlerProc(theWindow: WindowPtr; handlerRefCon: UNIV Ptr; theDragRef: DragReference; userRoutine: DragReceiveHandlerUPP): OSErr;
  183.     {$IFC NOT GENERATINGCFM}
  184.     INLINE $205F, $4E90;
  185.     {$ENDC}
  186.     
  187. TYPE
  188.     DragReceiveHandler = DragReceiveHandlerUPP;
  189.  
  190. { Application-Defined Routines }
  191.     DragSendDataProcPtr = ProcPtr;  { FUNCTION DragSendData(theType: FlavorType; dragSendRefCon: UNIV Ptr; theItemRef: ItemReference; theDragRef: DragReference): OSErr; }
  192.     DragSendDataUPP = UniversalProcPtr;
  193.  
  194. CONST
  195.     uppDragSendDataProcInfo = $00003FE0; { FUNCTION (4 byte param, 4 byte param, 4 byte param, 4 byte param): 2 byte result; }
  196.  
  197. FUNCTION NewDragSendDataProc(userRoutine: DragSendDataProcPtr): DragSendDataUPP;
  198.     {$IFC NOT GENERATINGCFM }
  199.     INLINE $2E9F;
  200.     {$ENDC}
  201.  
  202. FUNCTION CallDragSendDataProc(theType: FlavorType; dragSendRefCon: UNIV Ptr; theItemRef: ItemReference; theDragRef: DragReference; userRoutine: DragSendDataUPP): OSErr;
  203.     {$IFC NOT GENERATINGCFM}
  204.     INLINE $205F, $4E90;
  205.     {$ENDC}
  206.     
  207. TYPE
  208.     DragSendDataProc = DragSendDataUPP;
  209.  
  210.     DragInputProcPtr = ProcPtr;  { FUNCTION DragInput(VAR mouse: Point; VAR modifiers: INTEGER; dragInputRefCon: UNIV Ptr; theDragRef: DragReference): OSErr; }
  211.     DragInputUPP = UniversalProcPtr;
  212.  
  213. CONST
  214.     uppDragInputProcInfo = $00003FE0; { FUNCTION (4 byte param, 4 byte param, 4 byte param, 4 byte param): 2 byte result; }
  215.  
  216. FUNCTION NewDragInputProc(userRoutine: DragInputProcPtr): DragInputUPP;
  217.     {$IFC NOT GENERATINGCFM }
  218.     INLINE $2E9F;
  219.     {$ENDC}
  220.  
  221. FUNCTION CallDragInputProc(VAR mouse: Point; VAR modifiers: INTEGER; dragInputRefCon: UNIV Ptr; theDragRef: DragReference; userRoutine: DragInputUPP): OSErr;
  222.     {$IFC NOT GENERATINGCFM}
  223.     INLINE $205F, $4E90;
  224.     {$ENDC}
  225.     
  226. TYPE
  227.     DragInputProc = DragInputUPP;
  228.  
  229.     DragDrawingProcPtr = ProcPtr;  { FUNCTION DragDrawing(message: DragRegionMessage; showRegion: RgnHandle; showOrigin: Point; hideRegion: RgnHandle; hideOrigin: Point; dragDrawingRefCon: UNIV Ptr; theDragRef: DragReference): OSErr; }
  230.     DragDrawingUPP = UniversalProcPtr;
  231.  
  232. CONST
  233.     uppDragDrawingProcInfo = $000FFFA0; { FUNCTION (2 byte param, 4 byte param, 4 byte param, 4 byte param, 4 byte param, 4 byte param, 4 byte param): 2 byte result; }
  234.  
  235. FUNCTION NewDragDrawingProc(userRoutine: DragDrawingProcPtr): DragDrawingUPP;
  236.     {$IFC NOT GENERATINGCFM }
  237.     INLINE $2E9F;
  238.     {$ENDC}
  239.  
  240. FUNCTION CallDragDrawingProc(message: DragRegionMessage; showRegion: RgnHandle; showOrigin: Point; hideRegion: RgnHandle; hideOrigin: Point; dragDrawingRefCon: UNIV Ptr; theDragRef: DragReference; userRoutine: DragDrawingUPP): OSErr;
  241.     {$IFC NOT GENERATINGCFM}
  242.     INLINE $205F, $4E90;
  243.     {$ENDC}
  244.     
  245. TYPE
  246.     DragDrawingProc = DragDrawingUPP;
  247.  
  248. { Drag Manager Routines }
  249. { Installing and Removing Drag Handlers }
  250.  
  251. FUNCTION InstallTrackingHandler(trackingHandler: DragTrackingHandler; theWindow: WindowPtr; handlerRefCon: UNIV Ptr): OSErr;
  252.     {$IFC NOT GENERATINGCFM}
  253.     INLINE $7001, $ABED;
  254.     {$ENDC}
  255. FUNCTION InstallReceiveHandler(receiveHandler: DragReceiveHandler; theWindow: WindowPtr; handlerRefCon: UNIV Ptr): OSErr;
  256.     {$IFC NOT GENERATINGCFM}
  257.     INLINE $7002, $ABED;
  258.     {$ENDC}
  259. FUNCTION RemoveTrackingHandler(trackingHandler: DragTrackingHandler; theWindow: WindowPtr): OSErr;
  260.     {$IFC NOT GENERATINGCFM}
  261.     INLINE $7003, $ABED;
  262.     {$ENDC}
  263. FUNCTION RemoveReceiveHandler(receiveHandler: DragReceiveHandler; theWindow: WindowPtr): OSErr;
  264.     {$IFC NOT GENERATINGCFM}
  265.     INLINE $7004, $ABED;
  266.     {$ENDC}
  267. { Creating and Disposing Drag References }
  268. FUNCTION NewDrag(VAR theDragRef: DragReference): OSErr;
  269.     {$IFC NOT GENERATINGCFM}
  270.     INLINE $7005, $ABED;
  271.     {$ENDC}
  272. FUNCTION DisposeDrag(theDragRef: DragReference): OSErr;
  273.     {$IFC NOT GENERATINGCFM}
  274.     INLINE $7006, $ABED;
  275.     {$ENDC}
  276. { Adding Drag Item Flavors }
  277. FUNCTION AddDragItemFlavor(theDragRef: DragReference; theItemRef: ItemReference; theType: FlavorType; dataPtr: UNIV Ptr; dataSize: Size; theFlags: FlavorFlags): OSErr;
  278.     {$IFC NOT GENERATINGCFM}
  279.     INLINE $7007, $ABED;
  280.     {$ENDC}
  281. FUNCTION SetDragItemFlavorData(theDragRef: DragReference; theItemRef: ItemReference; theType: FlavorType; dataPtr: UNIV Ptr; dataSize: Size; dataOffset: LONGINT): OSErr;
  282.     {$IFC NOT GENERATINGCFM}
  283.     INLINE $7009, $ABED;
  284.     {$ENDC}
  285. { Providing Drag Callback Procedures }
  286. FUNCTION SetDragSendProc(theDragRef: DragReference; sendProc: DragSendDataProc; dragSendRefCon: UNIV Ptr): OSErr;
  287.     {$IFC NOT GENERATINGCFM}
  288.     INLINE $700A, $ABED;
  289.     {$ENDC}
  290. FUNCTION SetDragInputProc(theDragRef: DragReference; inputProc: DragInputProc; dragInputRefCon: UNIV Ptr): OSErr;
  291.     {$IFC NOT GENERATINGCFM}
  292.     INLINE $700B, $ABED;
  293.     {$ENDC}
  294. FUNCTION SetDragDrawingProc(theDragRef: DragReference; drawingProc: DragDrawingProc; dragDrawingRefCon: UNIV Ptr): OSErr;
  295.     {$IFC NOT GENERATINGCFM}
  296.     INLINE $700C, $ABED;
  297.     {$ENDC}
  298. FUNCTION TrackDrag(theDragRef: DragReference; {CONST}VAR theEvent: EventRecord; theRegion: RgnHandle): OSErr;
  299.     {$IFC NOT GENERATINGCFM}
  300.     INLINE $700D, $ABED;
  301.     {$ENDC}
  302. { Getting Drag Item Information }
  303. FUNCTION CountDragItems(theDragRef: DragReference; VAR numItems: INTEGER): OSErr;
  304.     {$IFC NOT GENERATINGCFM}
  305.     INLINE $700E, $ABED;
  306.     {$ENDC}
  307. FUNCTION GetDragItemReferenceNumber(theDragRef: DragReference; index: INTEGER; VAR theItemRef: ItemReference): OSErr;
  308.     {$IFC NOT GENERATINGCFM}
  309.     INLINE $700F, $ABED;
  310.     {$ENDC}
  311. FUNCTION CountDragItemFlavors(theDragRef: DragReference; theItemRef: ItemReference; VAR numFlavors: INTEGER): OSErr;
  312.     {$IFC NOT GENERATINGCFM}
  313.     INLINE $7010, $ABED;
  314.     {$ENDC}
  315. FUNCTION GetFlavorType(theDragRef: DragReference; theItemRef: ItemReference; index: INTEGER; VAR theType: FlavorType): OSErr;
  316.     {$IFC NOT GENERATINGCFM}
  317.     INLINE $7011, $ABED;
  318.     {$ENDC}
  319. FUNCTION GetFlavorFlags(theDragRef: DragReference; theItemRef: ItemReference; theType: FlavorType; VAR theFlags: FlavorFlags): OSErr;
  320.     {$IFC NOT GENERATINGCFM}
  321.     INLINE $7012, $ABED;
  322.     {$ENDC}
  323. FUNCTION GetFlavorDataSize(theDragRef: DragReference; theItemRef: ItemReference; theType: FlavorType; VAR dataSize: Size): OSErr;
  324.     {$IFC NOT GENERATINGCFM}
  325.     INLINE $7013, $ABED;
  326.     {$ENDC}
  327. FUNCTION GetFlavorData(theDragRef: DragReference; theItemRef: ItemReference; theType: FlavorType; dataPtr: UNIV Ptr; VAR dataSize: Size; dataOffset: LONGINT): OSErr;
  328.     {$IFC NOT GENERATINGCFM}
  329.     INLINE $7014, $ABED;
  330.     {$ENDC}
  331. FUNCTION GetDragItemBounds(theDragRef: DragReference; theItemRef: ItemReference; VAR itemBounds: Rect): OSErr;
  332.     {$IFC NOT GENERATINGCFM}
  333.     INLINE $7015, $ABED;
  334.     {$ENDC}
  335. FUNCTION SetDragItemBounds(theDragRef: DragReference; theItemRef: ItemReference; {CONST}VAR itemBounds: Rect): OSErr;
  336.     {$IFC NOT GENERATINGCFM}
  337.     INLINE $7016, $ABED;
  338.     {$ENDC}
  339. FUNCTION GetDropLocation(theDragRef: DragReference; VAR dropLocation: AEDesc): OSErr;
  340.     {$IFC NOT GENERATINGCFM}
  341.     INLINE $7017, $ABED;
  342.     {$ENDC}
  343. FUNCTION SetDropLocation(theDragRef: DragReference; {CONST}VAR dropLocation: AEDesc): OSErr;
  344.     {$IFC NOT GENERATINGCFM}
  345.     INLINE $7018, $ABED;
  346.     {$ENDC}
  347. { Getting Information About a Drag }
  348. FUNCTION GetDragAttributes(theDragRef: DragReference; VAR flags: DragAttributes): OSErr;
  349.     {$IFC NOT GENERATINGCFM}
  350.     INLINE $7019, $ABED;
  351.     {$ENDC}
  352. FUNCTION GetDragMouse(theDragRef: DragReference; VAR mouse: Point; VAR pinnedMouse: Point): OSErr;
  353.     {$IFC NOT GENERATINGCFM}
  354.     INLINE $701A, $ABED;
  355.     {$ENDC}
  356. FUNCTION SetDragMouse(theDragRef: DragReference; pinnedMouse: Point): OSErr;
  357.     {$IFC NOT GENERATINGCFM}
  358.     INLINE $701B, $ABED;
  359.     {$ENDC}
  360. FUNCTION GetDragOrigin(theDragRef: DragReference; VAR initialMouse: Point): OSErr;
  361.     {$IFC NOT GENERATINGCFM}
  362.     INLINE $701C, $ABED;
  363.     {$ENDC}
  364. FUNCTION GetDragModifiers(theDragRef: DragReference; VAR modifiers: INTEGER; VAR mouseDownModifiers: INTEGER; VAR mouseUpModifiers: INTEGER): OSErr;
  365.     {$IFC NOT GENERATINGCFM}
  366.     INLINE $701D, $ABED;
  367.     {$ENDC}
  368. { Drag Highlighting }
  369. FUNCTION ShowDragHilite(theDragRef: DragReference; hiliteFrame: RgnHandle; inside: BOOLEAN): OSErr;
  370.     {$IFC NOT GENERATINGCFM}
  371.     INLINE $701E, $ABED;
  372.     {$ENDC}
  373. FUNCTION HideDragHilite(theDragRef: DragReference): OSErr;
  374.     {$IFC NOT GENERATINGCFM}
  375.     INLINE $701F, $ABED;
  376.     {$ENDC}
  377. FUNCTION DragPreScroll(theDragRef: DragReference; dH: INTEGER; dV: INTEGER): OSErr;
  378.     {$IFC NOT GENERATINGCFM}
  379.     INLINE $7020, $ABED;
  380.     {$ENDC}
  381. FUNCTION DragPostScroll(theDragRef: DragReference): OSErr;
  382.     {$IFC NOT GENERATINGCFM}
  383.     INLINE $7021, $ABED;
  384.     {$ENDC}
  385. FUNCTION UpdateDragHilite(theDragRef: DragReference; updateRgn: RgnHandle): OSErr;
  386.     {$IFC NOT GENERATINGCFM}
  387.     INLINE $7022, $ABED;
  388.     {$ENDC}
  389. { Drag Manager Utilities }
  390. FUNCTION WaitMouseMoved(initialMouse: Point): BOOLEAN;
  391.     {$IFC NOT GENERATINGCFM}
  392.     INLINE $7023, $ABED;
  393.     {$ENDC}
  394. FUNCTION ZoomRects({CONST}VAR fromRect: Rect; {CONST}VAR toRect: Rect; zoomSteps: INTEGER; acceleration: ZoomAcceleration): OSErr;
  395.     {$IFC NOT GENERATINGCFM}
  396.     INLINE $7024, $ABED;
  397.     {$ENDC}
  398. FUNCTION ZoomRegion(region: RgnHandle; zoomDistance: Point; zoomSteps: INTEGER; acceleration: ZoomAcceleration): OSErr;
  399.     {$IFC NOT GENERATINGCFM}
  400.     INLINE $7025, $ABED;
  401.     {$ENDC}
  402.  
  403. {$ALIGN RESET}
  404. {$POP}
  405.  
  406. {$SETC UsingIncludes := DragIncludes}
  407.  
  408. {$ENDC} {__DRAG__}
  409.  
  410. {$IFC NOT UsingIncludes}
  411.  END.
  412. {$ENDC}
  413.